#define _CRT_SECURE_NO_WARNINGS 1

//leetcode 26

int removeDuplicates(int* nums, int numsSize) {
    int dest = 0;
    int src = 0;
    while (src < numsSize)
    {
        if (nums[src] == nums[dest])
        {
            nums[dest] = nums[src];
            src++;
        }
        else
        {
            dest++;
            nums[dest] = nums[src];
            src++;
        }
    }
    return dest + 1;


}

//leetcode 88

void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n)
{

    int* ret = (int*)malloc(sizeof(int) * (m + n));
    int cur1 = 0, cur2 = 0, dest = 0;


    while (cur1 < m && cur2 < n)
    {

        if (nums1[cur1] <= nums2[cur2])
            ret[dest++] = nums1[cur1++];

        else
            ret[dest++] = nums2[cur2++];
    }


    while (cur1 < m)
        ret[dest++] = nums1[cur1++];
    while (cur2 < n)
        ret[dest++] = nums2[cur2++];

    for (int i = 0; i < m + n; i++)
    {
        nums1[i] = ret[i];
    }


    free(ret);
}